<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of ListSubFamilyPage
 *
 * @author julien
 */
require_once 'Classes/View/DefaultHTMLPage.php';
require_once 'Classes/View/AbstractedViewItems/CellItem.php';
require_once 'Classes/View/ViewItems/ListItem.php';

class ListSubFamiliesPage extends DefaultHTMLPage{
    private $subfamilies;
    public function __construct($subFamily=null,$title="Sub Families") {
        parent::__construct($title);
        $this->addSubFamily($subFamily);
    }
    
    public function addSubFamily($subFamily){
        if(is_array($subFamily)){
            foreach ($subFamily as $key => $value) {
                $this->addSubFamily($value);
            }
        }
        else if(is_a($subFamily,"Sub_Family")){
            $lastElement = count($this->subfamilies);
            $this->subfamilies[$lastElement] = new CellItem();
            $this->subfamilies[$lastElement]->setTitle($subFamily->getName());
            
            
            $listOpt = new ListItem();
            $listOpt->setClass("OptList");
            foreach ($subFamily->getOptionalFields() as $key => $value) {
                $listOpt->addElement($key." : ".$value);
            }
            $this->subfamilies[$lastElement]->addContent($listOpt);
            
            $this->addContent($this->subfamilies[$lastElement]);
        }
    }
}

?>
